<template>
  <div>
    <div class="gl_searchBox gl_mb_15">
      <el-row :gutter="20">
        <el-col :md="6" :lg="5">
          <p>注册个人用户证件号码</p>
          <el-input v-model="idcardNumber" placeholder="请输入" size="mini" clearable @change="getPageList()" />
        </el-col>
        <el-col :md="6" :lg="4" class="search_btn">
          <el-button type="primary" size="mini" @click="getPageList()">查询</el-button>
        </el-col>
      </el-row>
    </div>
    <el-table v-loading="loading" class="gl_table_noBorder" :data="tableData" size="mini">
      <el-table-column prop="userName" label="个人用户姓名" :min-width="150" />
      <el-table-column prop="idCardNumber" label="证件号码" :min-width="200" />
      <el-table-column prop="accountName" label="绑定账号" :min-width="150" />
      <el-table-column label="操作" width="150" fixed="right">
        <template slot-scope="{ row }">
          <el-button size="mini" type="text" @click="clickEdit(row)">绑定账号解除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {
  api_POST_EventsManagementRegisterIdUnbindRegisterIdcard, // 个人资料绑定账号查询
  api_POST_EventsManagementRegisterAccountRegisterInfo // 解绑账号个人资料
} from '@/extend/api/game.js';
export default {
  data() {
    return {
      idcardNumber: '',
      loading: false,
      tableData: []
    };
  },
  methods: {
    // 获取数据
    getPageList(page) {
      this.loading = true;
      api_POST_EventsManagementRegisterAccountRegisterInfo({ 'idcardNumber': this.idcardNumber }).then(res => {
        this.loading = false;
        this.tableData = res ? [res] : [];
      }, error => {
        this.loading = false;
        const _msg = error.error.message || error.message;
        this.$message({ type: 'error', message: _msg });
      });
    },
    // 绑定账号解除
    clickEdit (row) {
      const that = this;
      this.$confirm(`您确定要解除此用户的绑定账号吗？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          api_POST_EventsManagementRegisterIdUnbindRegisterIdcard(row.registerId).then(res => {
            that.$message({ type: 'success', message: '绑定账号解除成功' });
            that.getPageList();
          }, error => {
            const _msg = error.message || error.error.message;
            that.$message({ type: 'error', message: _msg });
          });
        })
        .catch(() => {
        });
    }
  }
};
</script>

<style scoped>
</style>
